<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Instantiates an SQLite3 object and opens an SQLite 3 database</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="sqlite3.close.html">SQLite3::close</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="sqlite3.createaggregate.html">SQLite3::createAggregate</a></div>
 <div class="up"><a href="class.sqlite3.html">SQLite3</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="sqlite3.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SQLite3::__construct</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0)</p><p class="refpurpose"><span class="refname">SQLite3::__construct</span> &mdash; <span class="dc-title">
   Instantiates an SQLite3 object and opens an SQLite 3 database
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-sqlite3.construct-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>SQLite3::__construct</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$encryption_key</code></span>
  ]] )</div>

  <p class="para rdfs-comment">
   Instantiates an SQLite3 object and opens a connection to an
   SQLite 3 database. If the build includes encryption, then it will attempt
   to use the key.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-sqlite3.construct-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">filename</code></em></dt>

     <dd>

      <p class="para">
       Path to the SQLite database, or <em>:memory:</em> to use in-memory database.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">flags</code></em></dt>

     <dd>

      <p class="para">
       Optional flags used to determine how to open the SQLite database. By
       default, open uses <em>SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE</em>.
       <ul class="itemizedlist">
        <li class="listitem">
         <p class="para">
          <em>SQLITE3_OPEN_READONLY</em>: Open the database for
          reading only.
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <em>SQLITE3_OPEN_READWRITE</em>: Open the database for
          reading and writing.
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <em>SQLITE3_OPEN_CREATE</em>: Create the database if it
          does not exist.
         </p>
        </li>
       </ul>
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">encryption_key</code></em></dt>

     <dd>

      <p class="para">
       An optional encryption key used when encrypting and decrypting an
       SQLite database.
      </p>
     </dd>

    
   </dl>

  </p>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-sqlite3.construct-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an SQLite3 object on success.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-sqlite3.construct-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   Throws an <a href="class.exception.html" class="classname">Exception</a> on failure.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-sqlite3.construct-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2090">
    <p><strong>Example #1 <span class="function"><strong>SQLite3::__construct()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$db&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SQLite3</span><span style="color: #007700">(</span><span style="color: #DD0000">'mysqlitedb.db'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">exec</span><span style="color: #007700">(</span><span style="color: #DD0000">'CREATE&nbsp;TABLE&nbsp;foo&nbsp;(bar&nbsp;STRING)'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">exec</span><span style="color: #007700">(</span><span style="color: #DD0000">"INSERT&nbsp;INTO&nbsp;foo&nbsp;(bar)&nbsp;VALUES&nbsp;('This&nbsp;is&nbsp;a&nbsp;test')"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">'SELECT&nbsp;bar&nbsp;FROM&nbsp;foo'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">fetchArray</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="sqlite3.close.html">SQLite3::close</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="sqlite3.createaggregate.html">SQLite3::createAggregate</a></div>
 <div class="up"><a href="class.sqlite3.html">SQLite3</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
